//
//  FQPrivacyListViewController.swift
//  SwiftProject
//
//  Created by 董駸 on 2022/8/19.
//

import UIKit

class FQPrivacyListViewController: BaseViewController, UITableViewDelegate, UITableViewDataSource{
    
    let mainTable = UITableView(frame: .zero, style: .plain)
    let dataArray : [String] = ["《宝银钱包-用户注册服务协议》",
                                "《宝银钱包-隐私协议》",
                                "《宝银钱包-个人信息授权及使用声明》",
                                "《宝银钱包-非学生承诺书》"]
    
    override func viewDidLoad() {
        super.viewDidLoad()
        navigationBarType = .light
    }
    
    override func initSubviews() {
        super.initSubviews()
        
        mainTable.dataSource = self
        mainTable.delegate = self
        mainTable.register(BaseTableViewCell.self, forCellReuseIdentifier: "cell")
        mainTable.backgroundColor = .qmui_color(withHexString: "f5f5f5")
        mainTable.rowHeight = 50
        view.addSubview(mainTable)
        
        mainTable.snp.makeConstraints { make in
            make.left.right.bottom.equalToSuperview()
            make.top.equalTo(NavigationContentTop)
        }
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        dataArray.count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "cell")
        cell?.textLabel?.text = dataArray[indexPath.row]
        cell?.accessoryType = .disclosureIndicator
        return cell!
    }
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableView.deselectRow(at: indexPath, animated: true)
        let vc = BaseWebViewController(.local("agreement0\(indexPath.row + 1)", "html"))
        navigationController?.qmui_pushViewController(vc, animated: true)
    }
    
    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        16
    }
    
    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        nil
    }

    override func setupNavigationItems() {
        super.setupNavigationItems()
        title = "协议"
    }
}
